<?php

class Admin_ShopController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    	$this->view->headScript()->appendFile($this->view->baseUrl().'/js/jquery-1.8.1.min.js');
    }

    public function indexAction()
    {
        // action body
        $form=new Application_Form_Shop();
        $this->view->form=$form;
        
        if($this->getRequest()->isPost()){
        	$formData=$this->getRequest()->getPost();
        	if($form->isValid($formData)){
        		$nick_name=$form->getValue('nice_name');
        		$shop_util=new Txy_Util_TaobaoShop();
        		$shop_util->addNewShop((string)$nick_name);
        	}
        }
        $db_shop=new Application_Model_DbTable_Shop();
        $this->view->shopList=$db_shop->getUnConvertedShop();
    }
    
    public function convertedAction(){
    	$sid=$this->getRequest()->getParam("sid");
    	$url_spell=$this->getRequest()->getParam("url_spell");
    	$key_words=$this->getRequest()->getParam("key_words");
    	$click_url=$this->getRequest()->getParam("click_url");
    	$description=$this->getRequest()->getParam("description");
    	$data=Array();
    	$data['url_spell']=$url_spell;
    	$data['key_words']=$key_words;
    	$data['description']=$description;
    	$data['click_url']=$click_url;
    	$db_shop=new Application_Model_DbTable_Shop();
    	$db_shop->updateConvertedShop($data,$sid);
    	$this->_helper->redirector('index','shop','admin');
    }


}

